<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\Relations\belongsTo;
use Hyperf\Database\Model\SoftDeletes;

/**
 * @property int $id 
 * @property int $user_id 
 * @property int $goods_id 
 * @property int $num 
 * @property float $joined_price 
 * @property int $sku_id 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $deleted_at
 * @property GoodsSku $sku
 * @property Goods $goods
 */
class UserCart extends Model
{
    use SoftDeletes;

    public $dateFormat = 'U';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user_cart';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'user_id' => 'integer', 'goods_id' => 'integer', 'num' => 'integer', 'joined_price' => 'float', 'sku_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'integer'];

    /**
     * SKU 关联模型
     *
     * @return BelongsTo
     */
    public function sku(): belongsTo
    {
        return $this->belongsTo(GoodsSku::class, 'sku_id');
    }

    /**
     * 商品关联模型
     *
     * @return BelongsTo
     */
    public function goods(): belongsTo
    {
        return $this->belongsTo(Goods::class, 'goods_id');
    }
}